package cn.alusiaor.springbootaop.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zhuzhiping
 * @date 2019/12/9
 * @description 功能描述
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelResult<T> {
    private Integer code;
    private T data;
    private String msg;

    public ModelResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ModelResult defaultSuccessRsp() {
        ModelResult modelResult = new ModelResult(0, "success");
        return modelResult;
    }

    public static ModelResult successRspOnlyMsg(String msg) {
        ModelResult modelResult = new ModelResult(0, msg);
        return modelResult;
    }
    public static ModelResult successRspCodeAndMsg(Integer code, String msg) {
        ModelResult modelResult = new ModelResult(code,msg);
        return modelResult;
    }

    public static ModelResult successRspDataAndMsg(Object data, String msg) {
        ModelResult modelResult = new ModelResult(0, data, msg);
        return modelResult;
    }

    public static ModelResult successRspAll(Integer code, Object data, String msg) {
        ModelResult modelResult = new ModelResult(code, data, msg);
        return modelResult;
    }

    public static ModelResult defaultFailRsp() {
        ModelResult modelResult = new ModelResult(-1, "fail");
        return modelResult;
    }

    public static ModelResult failRspOnlyMsg(String msg) {
        ModelResult modelResult = new ModelResult(-1, msg);
        return modelResult;
    }

    public static ModelResult failRspCodeAndMsg(Integer code, String msg) {
        ModelResult modelResult = new ModelResult(code,msg);
        return modelResult;
    }

    public static ModelResult failRspDataAndMsg(Object data, String msg) {
        ModelResult modelResult = new ModelResult(-1, data, msg);
        return modelResult;
    }

    public static ModelResult failRspAll(Integer code, Object data, String msg) {
        ModelResult modelResult = new ModelResult(code, data, msg);
        return modelResult;
    }
}
